(function() {
    function Food (option = {}) {
        this.width = option.width ||20
        this.height = option.height||20
        this.x = option.x||0
        this.y = option.y||0
        this.color = option.color||"green"
        this.element = []
    }
    let ps = "absolute"
    Food.prototype.render = function(map) {
        var ele = document.createElement("div")
        this.x = Tool.getRandom(0,map.clientWidth/this.width-1)*this.width
        this.y = Tool.getRandom(0,map.clientHeight/this.height-1)*this.height
        ele.style.width =this.width + "px"
        ele.style.height = this.height + "px"
        ele.style.left = this.x + "px"
        ele.style.top = this.y + "px"
        ele.style.backgroundColor = this.color
        ele.style.position = ps
        ele.style.borderRadius = "50%"
        map.appendChild(ele)
        this.element.push(ele)
    }
    Food.prototype.remove = function (map,i) {
        map.removeChild(this.element[i])
        this.element.splice(i,1)
    }
    window.Food =Food;
})();
